<?php

use app\common\services\StaticServices;
use yii\helpers\Url;

?>

<?= Yii::$app->view->renderFile('@app/modules/admin/views/common/tab_user.php', ['tab' => 'index']) ?>
<div class="panel-content">
    <table class="ui selectable celled table">
        <input type="hidden" name="_csrf" id='csrf' value="<?= Yii::$app->request->csrfToken ?>">
        <thead>
        <tr>
            <th>人员姓名</th>
            <th>人员属性</th>
            <th>人员单位</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>

        <?php if ($list): ?>
            <?php foreach ($list as $item): ?>
                <tr>
                    <td><?= $item['user_name'] ?></td>
                    <td><?= StaticServices::getUserRole()[$item['user_role']] ?></td>
                    <?php if (isset($item['user_company'])): ?>
                        <td><?= $item['user_company'] ?></td>
                    <?php else: ?>
                        <td>无</td>
                    <?php endif; ?>
                    <td><?= date('Y-m-d', $item['create_time']) ?></td>
                    <td>
                        <a href="<?= Url::to(['/admin/user/set', 'id' => $item['id']]) ?>"><i
                                    class="edit icon"></i></a>
                        <a href="javascript:void (0)"><i class="trash alternate icon _del"
                                                         data-id="<?= $item['id'] ?>"></i></a>
                    </td>
                </tr>
            <?php endforeach; ?>
        <?php else: ?>
            <tr>
                <td colspan="4">暂无数据</td>
            </tr>
        <?php endif; ?>
        </tbody>

    </table>
</div>
<?= Yii::$app->view->renderFile('@app/modules/admin/views/common/page.php', ['total_page' => $total_page, 'p' => $p, 'url' => '/admin/user/index']) ?>
<script type="text/javascript">
    require(['modules/user/index'], function (index) {
        index.user_del()
    })
</script>
